# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.

# Changing variables in this file should only require a reload of PostgreSQL
# As the gitlab-psql user, run:
# /opt/gitlab/embedded/bin/pg_ctl reload -D /var/opt/gitlab/postgresql/data
work_mem = <%= @work_mem %>				# min 64kB
maintenance_work_mem = <%= @maintenance_work_mem %> # 16MB    # min 1MB
synchronous_commit = <%= @synchronous_commit %> # synchronization level; on, off, or local
synchronous_standby_names = '<%= @synchronous_standby_names %>'

# - Checkpoints -
min_wal_size = <%= @min_wal_size %>
max_wal_size = <%= @max_wal_size %>

checkpoint_timeout = <%= @checkpoint_timeout %>		# range 30s-1h, default 5min
checkpoint_completion_target = <%= @checkpoint_completion_target %>	# checkpoint target duration, 0.0 - 1.0, default 0.5
checkpoint_warning = <%= @checkpoint_warning %>		# 0 disables, default 30s

# - Logging -
<% if @log_destination %>
log_destination = '<%= @log_destination %>'
<% end %>
<% if @log_directory %>
log_directory = '<%= @log_directory %>'
<% end %>
<% if @log_filename %>
log_filename = '<%= @log_filename %>'
<% end %>
<% if @log_file_mode %>
log_file_mode = <%= @log_file_mode %>
<% end %>
<% if @log_truncate_on_rotation %>
log_truncate_on_rotation = <%= @log_truncate_on_rotation %>
<% end %>
<% if @log_rotation_age %>
log_rotation_age = <%= @log_rotation_age %>
<% end %>
<% if @log_rotation_size %>
log_rotation_size = <%= @log_rotation_size %>
<% end %>

# - Archiving -
archive_command = '<%= @archive_command %>'   # command to use to archive a logfile segment
archive_timeout = <%= @archive_timeout %>    # force a logfile segment switch after this
        # number of seconds; 0 disables

# - Replication
<% if (pg_helper.database_version || pg_helper.version).major.to_f >= 13 %>
wal_keep_size = <%= @wal_keep_size %>
<% else %>
wal_keep_segments = <%= @wal_keep_segments %>
<% end %>

max_standby_archive_delay = <%= @max_standby_archive_delay %> # max delay before canceling queries
          # when reading WAL from archive;
          # -1 allows indefinite delay
max_standby_streaming_delay = <%= @max_standby_streaming_delay %> # max delay before canceling queries
          # when reading streaming WAL;
          # -1 allows indefinite delay

hot_standby_feedback = <%= @hot_standby_feedback %>   # send info from standby to prevent
          # query conflicts

# - Planner Cost Constants -
#seq_page_cost = 1.0      # measured on an arbitrary scale
<% if @random_page_cost %>
random_page_cost = <%= @random_page_cost %>     # same scale as above
<% end %>

effective_cache_size = <%= @effective_cache_size %> # Default 128MB

log_min_duration_statement = <%= @log_min_duration_statement %>  # -1 is disabled, 0 logs all statements
          # and their durations, > 0 logs only
          # statements running at least this number
          # of milliseconds

<% if @log_checkpoints %>
log_checkpoints = <%= @log_checkpoints %>
<% end %>

log_line_prefix = '<%= @log_line_prefix %>' # default '', special values:
          #   %a = application name
          #   %u = user name
          #   %d = database name
          #   %r = remote host and port
          #   %h = remote host
          #   %p = process ID
          #   %t = timestamp without milliseconds
          #   %m = timestamp with milliseconds
          #   %i = command tag
          #   %e = SQL state
          #   %c = session ID
          #   %l = session line number
          #   %s = session start timestamp
          #   %v = virtual transaction ID
          #   %x = transaction ID (0 if none)
          #   %q = stop here in non-session
          #        processes
          #   %% = '%'

<% if @log_temp_files %>
log_temp_files = <%= @log_temp_files %>      # log temporary files equal or larger
          # than the specified size in kilobytes;
          # -1 disables, 0 logs all temp files
<% end %>

<% if @log_statement %>
log_statement = '<%= @log_statement %>' # none, ddl, mod, all
<% end %>

# - Autovacuum parameters -
autovacuum = <%= @autovacuum %> # Enable autovacuum subprocess?  'on'
          # requires track_counts to also be on.

log_autovacuum_min_duration = <%= @log_autovacuum_min_duration %> # -1 disables, 0 logs all actions and
          # their durations, > 0 logs only
          # actions running at least this number
          # of milliseconds.

autovacuum_naptime = <%= @autovacuum_naptime %> # time between autovacuum runs
autovacuum_vacuum_threshold = <%= @autovacuum_vacuum_threshold %> # min number of row updates before
          # vacuum
autovacuum_analyze_threshold = <%= @autovacuum_analyze_threshold %> # min number of row updates before
          # analyze
autovacuum_vacuum_scale_factor = <%= @autovacuum_vacuum_scale_factor %> # fraction of table size before vacuum
autovacuum_analyze_scale_factor = <%= @autovacuum_analyze_scale_factor %> # fraction of table size before analyze
autovacuum_vacuum_cost_delay = <%= @autovacuum_vacuum_cost_delay %> # default vacuum cost delay for
          # autovacuum, in milliseconds;
          # -1 means use vacuum_cost_delay
autovacuum_vacuum_cost_limit = <%= @autovacuum_vacuum_cost_limit %> # default vacuum cost limit for
          # autovacuum, -1 means use
          # vacuum_cost_limit

# Parameters for gathering statistics
default_statistics_target = <%= @default_statistics_target %>

# - Client connection timeouts
statement_timeout = <%= @statement_timeout %>

idle_in_transaction_session_timeout = <%= @idle_in_transaction_session_timeout %>

# IO settings
effective_io_concurrency = <%= @effective_io_concurrency %>
track_io_timing = '<%= @track_io_timing %>'

# Parallel worker settings
max_worker_processes = <%= @max_worker_processes %>
max_parallel_workers_per_gather = <%= @max_parallel_workers_per_gather %>

# Deadlock handling and logging
deadlock_timeout = '<%= @deadlock_timeout %>'
log_lock_waits = <%= @log_lock_waits %>

# - Locale and Formatting -
datestyle = 'iso, mdy'

# These settings are initialized by initdb, but they can be changed.
lc_messages = 'C'     # locale for system error message
          # strings
lc_monetary = 'C'     # locale for monetary formatting
lc_numeric = 'C'      # locale for number formatting
lc_time = 'C'       # locale for time formatting

# default configuration for text search
default_text_search_config = 'pg_catalog.english'
